package com.sun.baizhi.springboot;

import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
public class FanoutConsumer {
    @RabbitListener(bindings = {@QueueBinding(
            value = @Queue(),
            exchange = @Exchange(name = "logs",type = "fanout"))})
    public void getMsg1(String message){
        System.out.println("消费者1=====================" + message);
    }
    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue(),  //随机生成队列
                    exchange = @Exchange(name = "logs",type = "fanout") //绑定的交换机

            )
    })
    public void getMsg2(String message){
        System.out.println("消费者2=====================" + message);
    }
}
